-- CALC_CAVE_35_TARGET_CLASS

-- 计算钢铁之门废墟的中心格子类型
return function()
    local wreckage  = { ["class"] = 293,  ["ratio"] = 60 };  -- 研究员的残骸
    local wreckage2 = { ["class"] = 294,  ["ratio"] = 20 };  -- 探员J的残骸
    local wreckage3 = { ["class"] = 295,  ["ratio"] = 20 };  -- 探员K的残骸
    local wreckage4 = { ["class"] = 296,  ["ratio"] = 20 };  -- 避难者的残骸

    local arr = { wreckage, wreckage2, wreckage3, wreckage4};

    -- 探员J\探员K的残骸，一共只出现一次
    if DungeonInstanceM.getInstanceStat(wreckage2["class"]) > 0 or
        DungeonInstanceM.getInstanceStat(wreckage3["class"]) > 0 then
        wreckage2["ratio"] = 0;
        wreckage3["ratio"] = 0;
    end

    -- 避难者的残骸只出现一次
    if DungeonInstanceM.getInstanceStat(wreckage4["class"]) > 0 then
        wreckage4["ratio"] = 0;
    end

    -- 迷宫小关不出现
    local dungeonId = DungeonM.getDungeonId();
    if type(dungeonId) == "number" and dungeonId > 0 and
        DungeonAreaM.query(dungeonId, "type") == "child" then
        wreckage2["ratio"] = 0;
        wreckage3["ratio"] = 0;
        wreckage4["ratio"] = 0;
    end

    -- 先过滤一遍
    DungeonInstanceM.filterInstanceGrids(arr);

    local seed = DungeonM.getRandSeed("CALC_CAVE_35_TARGET_CLASS");
    local info = fetchElemBySeed(arr, seed);

    return info["class"];
end
